package com.pinyoumei.app.adapter;

import android.graphics.Color;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.pinyoumei.app.R;
import com.pinyoumei.app.bean.ZBKOrderListBean;

import java.util.List;

/**
 * Created by Administrator on 2021-06-30.
 * --------- 日期 ------- 维护人 ------------ 变更内容 --------
 * 2021-06-30        Administrator             新增Person类
 * 2021-06-30        Administrator             增加sex属性
 */
public class IntegralOrderAdapter extends BaseQuickAdapter<ZBKOrderListBean.ResultBean.OrderListBean, BaseViewHolder> {
    public IntegralOrderAdapter(int layoutResId, @Nullable List<ZBKOrderListBean.ResultBean.OrderListBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, ZBKOrderListBean.ResultBean.OrderListBean item) {
            helper.addOnClickListener(R.id.bt_wl);
            helper.addOnClickListener(R.id.bt_xq);
            helper.addOnClickListener(R.id.bt_sure);

            helper.setText(R.id.tv_order_no,"订单编号：" + item.getOrder_no());
            helper.setText(R.id.tv_order_time,"下单时间：" + item.getOrder_time());

            TextView tv_order_status = helper.getView(R.id.tv_order_status);
            Button bt_wl = helper.getView(R.id.bt_wl);
            Button bt_xq = helper.getView(R.id.bt_xq);
            Button bt_sure = helper.getView(R.id.bt_sure);
            bt_wl.setVisibility(View.GONE);
            bt_xq.setVisibility(View.GONE);
            bt_sure.setVisibility(View.GONE);

            switch (item.getOrder_status()) {
//            1 待发货  2 待收货  3 已完成
//            待收货显示物流查询跟确认收货以及订单详情操作按钮 1和3显示订单详情操作按钮
            	case 1:
                    tv_order_status.setText("待发货");
                    tv_order_status.setTextColor(Color.parseColor("#009F83"));
                    bt_xq.setVisibility(View.VISIBLE);
            		break;
                case 2:
                    tv_order_status.setText("待收货");
                    tv_order_status.setTextColor(Color.parseColor("#448FF6"));

                    bt_wl.setVisibility(View.VISIBLE);
                    bt_xq.setVisibility(View.VISIBLE);
                    bt_sure.setVisibility(View.VISIBLE);
                    break;
                case 3:
                    tv_order_status.setText("已完成");
                    tv_order_status.setTextColor(Color.parseColor("#696969"));
                    bt_xq.setVisibility(View.VISIBLE);
                    break;
            	default:
            		break;
            }


        helper.setText(R.id.tv_total_goods_num,"共" + item.getTotal_goods_num() + "件商品");

        helper.setText(R.id.tv_real_pay_price,"" + item.getReal_pay_price());

        helper.setText(R.id.tv_unit_name,"" + item.getUnit_name());


        RecyclerView rv_1 = helper.getView(R.id.rv_1);
        rv_1.setLayoutManager(new StaggeredGridLayoutManager(1,StaggeredGridLayoutManager.VERTICAL));
        ZbkOrderInfoListAdapter zbkOrderInfoListAdapter = new ZbkOrderInfoListAdapter(R.layout.item_zbk_order_info,item.getGoods_list());
        rv_1.setAdapter(zbkOrderInfoListAdapter);
    }
}
